/// Author: QP
/// Version: 1.2
/// Date:2023/04/02
/// WS 时间戳数据类型类型
Class WS.DT.TimeStamp Extends %Library.TimeStamp [ ClassType = datatype, ClientDataType = TIMESTAMP, OdbcType = TIMESTAMP, SqlCategory = TIMESTAMP, System = 2 ]
{

/// Converts the value of <var>%val</var>, which is in logical format <code>YYYY-MM-DD HH:MM:SS[.nnnnnnnnn]</code>, into a display string.
/// The Logical value and Display values are the same unless there are <a href="#VALUELIST">VALUELIST</a> and <a href="#DISPLAYLIST">DISPLAYLIST</a> parameters specified.
/// <p>Returns the Display Timestamp value of the Logical Timestamp string <var>%val</var>.
ClassMethod LogicalToDisplay(%val As %TimeStamp) As %String [ CodeMode = generator, ServerOnly = 0 ]
{
    If %parameter("VALUELIST")'="",%parameter("DISPLAYLIST")'="" {
        do GenerateValConv^%occLibrary(%parameter("VALUELIST"),%parameter("DISPLAYLIST"))
    } Else {
        Set %codemode=$$$cMETHCODEMODEEXPRESSION
        Set %code="$E($Replace($Replace($Replace(%val,""-"",""""),"":"",""""),"" "",""""),1,14)"
    }
    QUIT $$$OK
}

/// Converts the %TimeStamp value to the canonical SOAP encoded value.
ClassMethod LogicalToXSD(%val As %TimeStamp) As %String [ CodeMode = generator, ServerOnly = 1 ]
{
    If ($$$getClassType(%class)=$$$cCLASSCLASSTYPEDATATYPE) || $$$comMemberKeyGet(%class,$$$cCLASSparameter,"XMLENABLED",$$$cPARAMdefault) || $$$comMemberKeyGet(%class,$$$cCLASSparameter,"%JSONENABLED",$$$cPARAMdefault) {
        Set %codemode=$$$cMETHCODEMODEEXPRESSION
        Set %code="$E($Replace($Replace($Replace(%val,""-"",""""),"":"",""""),"" "",""""),1,14)"

    } Else {
        Set %code=0 
    }
    Quit $$$OK
}

ClassMethod DisplayToLogical(%val As %String) As %TimeStamp [ CodeMode = generator, ServerOnly = 0 ]
{
	If %parameter("VALUELIST")'="",%parameter("DISPLAYLIST")'="" {
		do GenerateValConv^%occLibrary(%parameter("DISPLAYLIST"),%parameter("VALUELIST"))
	} Else {
		Set %codemode=$$$cMETHCODEMODEEXPRESSION
		Set %code="$E(%val,1,4)_""-""_$E(%val,5,6)_""-""_$E(%val,7,8)_"" ""_$E(%val,9,10)_"":""_$E(%val,11,12)_"":""_$E(%val,13,14)"
	}
	QUIT $$$OK
}

}
